package com.ry.ryshopweb.controller;

import com.ry.ryshopweb.service.TestCats;
import com.ry.ryshopweb.service.TestItems;
import com.ry.ryshopweb.service.TestOrders;
import com.ry.ryshopweb.vo.Result;
import com.ry.ryshopweb.service.TestShop;
import com.ry.ryshopweb.vo.ShopItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@RestController
public class TestController {
    @Autowired
    private TestShop testShop;

    @Autowired
    private TestItems testItems;

    @Autowired
    private TestCats testCats;

    @Autowired
    private TestOrders testOrders;

    @RequestMapping("/shop/getShopMsg")
    public Result testgetShopMsg(){
        Long userId = 100l;
        return new Result(testShop.getShopMsg(userId));
    }
    @RequestMapping("/shop/ssoshopName")
    public Result testssoShopName(String shopName){
        System.out.println(shopName);
        return new Result();
    }
    @RequestMapping("/shop/saveShopMsg")
    public Result testSaveShopMsg(String shopName,String logo){
        System.out.println(shopName);
        System.out.println(logo);
        return new Result();
    }
    @RequestMapping("/shop/getItems")
    public Result testGetItems(Integer pageCurrent){
        return new Result(testItems.getItems(pageCurrent));
    }
    @RequestMapping("/shop/deleteitem")
    public Result testdeleteItem(Long itemId){
        System.out.println(itemId);
        return new Result();
    }
    @RequestMapping("/shop/getCats")
    public Result testGetCats(){
        return new Result(testCats.getCats());
    }
    @RequestMapping("/shop/edit")
    public Result testEdit(@RequestParam("image")MultipartFile[] image,@RequestParam("banner")MultipartFile[] banner,Long itemId,String title,Long price,Long catId,String sizeIds,String itemDesc,Long shopId){
        System.out.println("itemId:"+itemId);
        System.out.println("title:"+title);
        System.out.println("price:"+price);
        System.out.println("catId:"+catId);
        System.out.println("sizeIds:"+sizeIds);
        System.out.println("image:"+image);
        System.out.println("itemDesc:"+itemDesc);
        System.out.println("shopId:"+shopId);
        System.out.println("banner:"+banner);
        return new Result();
    }
    @RequestMapping("/shop/insert")
    public Result testInsert(@RequestParam("image")MultipartFile[] image,@RequestParam("banner")MultipartFile[] banner,Long itemId,String title,Long price,Long catId,String sizeIds,String itemDesc,Long shopId){
        System.out.println("itemId:"+itemId);
        System.out.println("title:"+title);
        System.out.println("price:"+price);
        System.out.println("catId:"+catId);
        System.out.println("sizeIds:"+sizeIds);
        System.out.println("image:"+image);
        System.out.println("itemDesc:"+itemDesc);
        System.out.println("shopId:"+shopId);
        System.out.println("banner:"+banner);
        return new Result();
    }
    @RequestMapping("/shop/getOrders")
    public Result testOrders(Integer pageCurrent){
        return new Result(testOrders.getOrders(pageCurrent));
    }
    @RequestMapping("/shop/deleteorder")
    public Result testDeleteOrder(String orderId){
        System.out.println(orderId);
        return new Result();
    }
    @RequestMapping("/shop/order/getorder")
    public Result testDoGetOrder(String orderId){
        System.out.println(orderId);
        return new Result(testOrders.getOrderItem(orderId));
    }
    @RequestMapping("/shop/dologin")
    public Result testLogin(String username,String password){
        System.out.println(username);
        System.out.println(password);
        return new Result();
    }
}
